	import * as echarts from 'echarts'
	const setOption:any = {
		Bar(attr:any, data:any, pramas1:any, pramas2:any){
			var colorList = ['#0033FF', '#9B42FF', '#E75F5F', '#f7290a', '#CE2B8D', '#488BFF', '#26CEBA', '#FFC069', '#FD6865', '#becce9', '#d90000'];
			var seriesArr = []
			for (var i = 0; i <= attr.legendArr.length-1; i++) {
				seriesArr.push({ 
					name: attr.legendArr[i],
					type: 'bar', 
					connectNulls:true,
					smooth: true,
					sampling: 'average', 
					large: true,
					animation: false,
					clip: true,   
					itemStyle: {
						color: function(list:any) {
							return colorList[list.dataIndex]
						}
					},
					yAxisIndex: 0,
					data: [],
				})
			}
			const option = {
				grid: [{
					left: '0%',
					bottom: '0%',
					right: '2%',
					height: "88%",
					containLabel: true
				}],
				tooltip: {
					backgroundColor:'rgba(0,0,0,0.5)',
					textStyle : {
						color: '#FFFFFF',
					},
					trigger: 'item',
					show: true,
					formatter: function (params:any) {
						return '时间：' + params.value[0] + '<br />幅值：' + (Math.floor((params.value[1]*100)/100)) + ' ' + attr.dw
					}
				},
				legend: {
					data: attr.legendArr,
					align:'left',
					x:'right',
					y: 'top',
					top: -2,
					icon: "roundRect", 
					itemWidth: 18,
					itemHeight: 12,
					textStyle: { 
						color: '#fff',
						rich: {
							a: {
								verticalAlign: 'middle',
							},
						},
						padding:[4,0,0,0], 
					},
				},
				dataZoom: [{
					type: 'inside', 
					show : true,  
					realtime : true, 
					startValue: 0, 
					endValue: 20
				}],
				xAxis:{
					type: 'category',
					// boundaryGap: false,
					// data: data.datax.map(function(str:any){ return str.replace(' ', '\n') }),
					// 轴线
					axisLine: {
						lineStyle: {
							color: '#113D72',
							fontSize: 12,
							type: 'dashed'
						}
					},
					//刻度线
					axisTick: {
						show: false, 
					},
					// 分割线
					splitLine: {
						show: false,
						lineStyle: {
							color: '#113D72',
							type: 'dashed'
						}
					},
					// 轴文字
					axisLabel: {
						color: '#0065FF',
						show: true,
						// interval: 0,
						// rotate: 20,
						fontSize: 12,
						formatter:function(value:any) { 
							return value.replace(' ', '\n') 
						}
					},
				},
				yAxis: [{
					name: '幅值' + attr.dw,
					nameGap: 15,
					nameTextStyle: {    
						padding: [60, 0, 0, 5],
						color: '#0065FF',
						fontWeight:'bold',
					},
					type: 'value',
					min: attr.min,
					max: attr.max,
					axisTick: {
						show: false,
					},
					axisLine: {
						show: true,
						lineStyle: {
							color: '#113D72',
							type: 'dashed'
						}
					},
					splitLine: {
						lineStyle: {
							color: '#113D72',
							type: 'dashed'
						}
					},
					axisLabel: {
						color: '#0065FF',
						formatter: '{value}'
					},
				}],
				series: seriesArr
			};
			return option
		},
		
	}

  // 字体自适应
  const newSize = (res:any) => {
    let clientWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
    if (!clientWidth) return;
    let fontSize = clientWidth / 1920; //设计稿尺寸
    return res * fontSize;  //转换为 rem的布局返回出去
  }

  // 颜色列表
  const colorList = [
    { colorStart:'#0033FF', colorEnd:'#00B7FF' },
    { colorStart:'#9B42FF', colorEnd:'#FF59FC' },
    { colorStart:'#E75F5F', colorEnd:'#FFCD45' },
    { colorStart:'#f7290a', colorEnd:'#f98371' },
    { colorStart:'#CE2B8D', colorEnd:'#FF9595' },
    { colorStart:'#488BFF', colorEnd:'#9abffd' },
    { colorStart:'#26CEBA', colorEnd:'#8efaed' },
    { colorStart:'#FFC069', colorEnd:'#fadfba' },
    { colorStart:'#FD6865', colorEnd:'#f8b2b1' },
    { colorStart:'#becce9', colorEnd:'#82a0df' }
  ]
  export default setOption

